#!/bin/bash  
local_ip="$(/sbin/ifconfig eth0|grep 'inet addr'|awk -F : '{print $2}'|cut -d ' ' -f1)" 
email='it-arch' 
user='root' 
passwd='mysqladmin' 
my_config='/etc/my.cnf' 
log=$(date +%Y%m%d%H%M).log  
str=$(date +%Y%m%d%H%M).tar.gz  
backup_dir='/backup/MySQL/xtrabackup' 
source='it-arch'
target='it-arch'
title='xtrabackup Mysql backup information'  
MailUser='it-arch' 
MailPassword='jyp20100'
content1='Server_name:'$(hostname)' Server_ip:'$local_ip' '$(date +"%y-%m-%d %H:%M:%S")' mysql full backup Success!'
content2='Server_name:'$(hostname)' Server_ip:'$local_ip' '$(date +"%y-%m-%d %H:%M:%S")' mysql full backup Faild!'
echo "Start to backup at $(date +%Y%m%d%H%M)"
if [ ! -d "$backup_dir" ];then  
    mkdir -p $backup_dir  
fi  
#innobackupex --defaults-file=$my_config --user=$user --password=$passwd  --database=$database --stream=tar $backup_dir 2>$backup_dir/$log | gzip 1>$backup_dir/$str  
innobackupex --defaults-file=$my_config --user=$user --password=$passwd   $backup_dir  
if [ $? -eq 0 ];then  
    echo "Backup is finish! at $(date +%Y%m%d%H%M)"  

    exit 0  
else  
    echo "Backup is Fail! at $(date +%Y%m%d%H%M)"  
    echo "Server_name:$(hostname) Server_ip:$local_ip $(date +"%y-%m-%d %H:%M:%S") mysql full backup Fail!"
    exit 1  
fi  
echo "Backup Process Done"
